import java.util.ArrayList;
import java.util.List;

public class Leet869 {
    public static void main(String[] args) {
        Leet869 l = new Leet869();
        System.out.println(l.reorderedPowerOf2(61));
    }
    public boolean reorderedPowerOf2(int n) {
        if (n==1)
            return true;
        int[] ns = new int[10];
        int wei = 0;
        while (n!=0){
            ns[n%10]++;
            n/=10;
            wei++;
        }
        long max = 1;
        for (int i = 0; i < wei; i++) {
            max = max*10;
        }
        long min = max/10;
        List<Long> list = new ArrayList<>();
        long t = 1;
        while (true){
            t*=2;
            if (t>=max)
                break;
            else if (t>=min)
                list.add(t);
        }
        for (Long aLong : list) {
            int[] tar = new int[10];
            while (aLong!=0){
                int te = Math.toIntExact(aLong % 10);
                tar[te]++;
                aLong/=10;
                wei++;
            }
            int i;
            for (i = 0; i < tar.length; i++) {
                if (tar[i]!=ns[i])
                    break;
            }
            if (i==10)
                return true;
        }
        return false;
    }
}
